package approve.action;

import java.util.List;

import resource.pojo.BuyingDocument;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class re_viewproduct_adapter extends BaseAdapter{
	Context context;
	List<BuyingDocument> listProducts;
	

	public re_viewproduct_adapter(Context context,List<BuyingDocument> listProducts) {
		super();
		this.context=context;
		this.listProducts = listProducts;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return listProducts.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return listProducts.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup arg2) {
		BuyingDocument buyDoc=listProducts.get(position);
		
		if(view==null){
			LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view=inflater.inflate(R.layout.view_product_adapter, null);
		}
		
		TextView productName=(TextView) view.findViewById(R.id.productname);
		productName.setText(buyDoc.getName()+" - "+buyDoc.getCompany());
		
		TextView price=(TextView) view.findViewById(R.id.price);
		price.setText("("+buyDoc.getPrice()+" _ "+buyDoc.getVat()+" x "+buyDoc.getAmount()+")");
		
		return view;
	}

}
